package com.hr.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hr.mapper.AoaTypeListMapper;
import com.hr.entity.AoaTypeList;
import com.hr.service.AoaTypeListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * (AoaTypeList)表服务实现类
 *
 * @author makejava
 * @since 2022-06-22 20:33:15
 */
@Service("aoaTypeListService")
public class AoaTypeListServiceImpl extends ServiceImpl<AoaTypeListMapper, AoaTypeList> implements AoaTypeListService {
    @Autowired
    private AoaTypeListMapper aoaTypeListMapper;

    /**
     * 查询与模糊查询
     * @param typeModel
     * @return
     */
    @Override
    public List<AoaTypeList> queryList(String typeModel) {
        if(typeModel!=null && !typeModel.isEmpty()){
            QueryWrapper<AoaTypeList> queryWrapper = new QueryWrapper<>();
            queryWrapper.like("type_model",typeModel);
            return aoaTypeListMapper.selectList(queryWrapper);
        }
        return aoaTypeListMapper.selectList(new QueryWrapper<>());
    }

    /**
     * 保存或修改
     * @param aoaTypeList
     * @return
     */
    @Override
    public boolean save(@RequestBody AoaTypeList aoaTypeList) {
        int row=0;
        if(aoaTypeList.getTypeId()==null){
            row=aoaTypeListMapper.insert(aoaTypeList);
        }else {
            row=aoaTypeListMapper.updateById(aoaTypeList);
        }
        return row>0;
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @Override
    public boolean delete(Integer id) {
        return aoaTypeListMapper.deleteById(id) > 0;
    }

    /**
     * 单值查询
     * @param id
     * @return
     */
    @Override
    public AoaTypeList queryById(Integer id) {
        return aoaTypeListMapper.selectById(id);
    }
}

